<template>
  <!-- <el-button text @click="dialogVisible = showStatusStore().dialogVisible">登录</el-button> -->
  <el-dialog v-model="dialogVisible" title="提示" width="30%">
    <span>{{ myPageType?.Usertype }}</span>
    <template #footer>
      <span class="dialog-footer">
        <el-button @click="cancelJump">取消</el-button>
        <el-button type="primary" @click="toRegister">确定</el-button>
      </span>
    </template>
  </el-dialog>
</template>

<script lang="ts" setup>
import { ref, defineEmits, watchEffect, watch } from "vue";

import showStatusStore from "@/store/modules/protocolDisplayStatus";

const oldUer = {
  Usertype: "您已注册，是否去登陆",
  toPage: false,
};
const newUser = {
  Usertype: "您还未注册，是否去注册？",
  toPage: true,
};
// const ishow = ref<boolean>();
const myPageType = ref<{ Usertype: string; toPage: boolean }>();
const emits = defineEmits(["change"]);
const dialogVisible = ref();
watch(
  () => showStatusStore().dialogVisible,
  () => {
    showStatusStore().myPage == "登录" ? (myPageType.value = newUser) : (myPageType.value = oldUer);
  }
);
const cancelJump = () => {
  showStatusStore().changeDialogVisible(false);
};
const toRegister = () => {
  emits("change", myPageType.value?.toPage);
  showStatusStore().changeDialogVisible(false);
};
watchEffect(() => {
  dialogVisible.value = showStatusStore().dialogVisible;
});
</script>
<style scoped>
.dialog-footer button:first-child {
  margin-right: 10px;
}
</style>
